package com.wz.jiangsu.controller.subscrible;

import org.springframework.web.bind.annotation.*;
import org.springframework.http.ResponseEntity;

import java.util.Map;

@RestController
public class DataReceiverController {

    // 接收 OpenGemini 推送的 POST 数据
    @PostMapping(value = "/",consumes = "application/octet-stream")
    public ResponseEntity<String> receiveData(@RequestBody Map<String, Object> data) {
        // 打印接收到的数据
        System.out.println("Received data: " + data);

        // 返回成功响应给 OpenGemini
        return ResponseEntity.ok("Data received successfully");
    }


    @PostMapping(value = "/write")
    public ResponseEntity<String> receiveData1(String db ,String rp ,String var3,String var4,String var5) {
        // 打印接收到的数据
        System.out.println("Received data: " + db + "---" + rp);

        // 返回成功响应给 OpenGemini
        return ResponseEntity.ok("Data received successfully");
    }



    @GetMapping(value = "/write",consumes = "application/octet-stream")
    public ResponseEntity<String> receiveData2(@RequestBody Map data) {
        // 打印接收到的数据
        System.out.println("Received data: " + data);

        // 返回成功响应给 OpenGemini
        return ResponseEntity.ok("Data received successfully");
    }

    @PutMapping (value = "/write",consumes = "application/octet-stream")
    public ResponseEntity<String> receiveData3(@RequestBody Map data) {
        // 打印接收到的数据
        System.out.println("Received data: " + data);

        // 返回成功响应给 OpenGemini
        return ResponseEntity.ok("Data received successfully");
    }
}
